package com.suxin.netty.coder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author Tang
 * @classname MyEncodeInt
 * @description [ TODO ]
 * @date 2021/1/8 22:00
 */
public class MyOutEncodeInt extends MessageToByteEncoder<Integer> {

    @Override
    protected void encode(ChannelHandlerContext ctx, Integer msg, ByteBuf out) throws Exception {
        // 编码器
        System.out.println("[" + ctx.channel().localAddress() + "] MyOutEncodeInt 出站 encode 被调用...msg：" + msg);
        out.writeInt(msg);
    }
}